From 3bc1edc4ab3406100319d5590d259ff0bc203b5a Mon Sep 17 00:00:00 2001 From: "cl349@firebug.cl.cam.ac.uk" Date: Sat, 3 Sep 2005 18:48:39 +0000 Subject: [PATCH] Update suspend/resume for new console code. - translate console mfn to pfn - unbind/bind console evtchn - recover console mfn on restore - trigger xenconsoled refresh after mfn is put in store Signed-off-by: Christian Limpach --- linux-2.6-xen-sparse/arch/xen/kernel/reboot.c | 7 +++++++ .../drivers/xen/console/xencons_ring.c | 13 ++++++++----- tools/libxc/xc_linux_restore.c | 6 +++++- tools/libxc/xc_linux_save.c | 6 ++++++ tools/libxc/xenguest.h | 3 ++- tools/python/xen/xend/XendCheckpoint.py | 19 +++++++++++++++---- tools/python/xen/xend/XendDomainInfo.py | 2 +- tools/xcutils/xc_restore.c | 19 ++++++++++++------- 8 files changed, 56 insertions(+), 19 deletions(-) diff --git a/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c b/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c index 82448a527e..af06ae5a58 100644 --- a/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c +++ b/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c @@ -96,6 +96,9 @@ static int __do_suspend(void *ignore) int restore_vcpu_context(int vcpu, vcpu_guest_context_t *ctxt); #endif + extern void xencons_suspend(void); + extern void xencons_resume(void); + int err = 0; BUG_ON(smp_processor_id() != 0); @@ -169,6 +172,8 @@ static int __do_suspend(void *ignore) smp_suspend(); #endif + xencons_suspend(); + xenbus_suspend(); ctrl_if_suspend(); @@ -214,6 +219,8 @@ static int __do_suspend(void *ignore) xenbus_resume(); + xencons_resume(); + #ifdef CONFIG_SMP smp_resume(); #endif diff --git a/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c b/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c index 6987d1a258..6083c6a326 100644 --- a/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c +++ b/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c @@ -101,19 +101,17 @@ int xencons_ring_init(void) if (!xen_start_info.console_evtchn) return 0; - err = bind_evtchn_to_irqhandler( - xen_start_info.console_evtchn, handle_input, - 0, "xencons", inring()); + err = bind_evtchn_to_irqhandler(xen_start_info.console_evtchn, + handle_input, 0, "xencons", inring()); if (err) { xprintk("XEN console request irq failed %i\n", err); - unbind_evtchn_from_irq(xen_start_info.console_evtchn); return err; } return 0; } -void xencons_suspend_comms(void) +void xencons_suspend(void) { if (!xen_start_info.console_evtchn) @@ -122,3 +120,8 @@ void xencons_suspend_comms(void) unbind_evtchn_from_irqhandler(xen_start_info.console_evtchn, inring()); } +void xencons_resume(void) +{ + + (void)xencons_ring_init(); +} diff --git a/tools/libxc/xc_linux_restore.c b/tools/libxc/xc_linux_restore.c index 9e55bb1266..9e3acb8d81 100644 --- a/tools/libxc/xc_linux_restore.c +++ b/tools/libxc/xc_linux_restore.c @@ -53,7 +53,8 @@ read_exact(int fd, void *buf, size_t count) } int xc_linux_restore(int xc_handle, int io_fd, u32 dom, unsigned long nr_pfns, - unsigned int store_evtchn, unsigned long *store_mfn) + unsigned int store_evtchn, unsigned long *store_mfn, + unsigned int console_evtchn, unsigned long *console_mfn) { dom0_op_t op; int rc = 1, i, n, k; @@ -486,6 +487,9 @@ int xc_linux_restore(int xc_handle, int io_fd, u32 dom, unsigned long nr_pfns, *store_mfn = p_srec->resume_info.store_mfn = pfn_to_mfn_table[p_srec->resume_info.store_mfn]; p_srec->resume_info.store_evtchn = store_evtchn; + *console_mfn = p_srec->resume_info.console_mfn = + pfn_to_mfn_table[p_srec->resume_info.console_mfn]; + p_srec->resume_info.console_evtchn = console_evtchn; munmap(p_srec, PAGE_SIZE); /* Uncanonicalise each GDT frame number. */ diff --git a/tools/libxc/xc_linux_save.c b/tools/libxc/xc_linux_save.c index d0797b15ae..de4480dee4 100644 --- a/tools/libxc/xc_linux_save.c +++ b/tools/libxc/xc_linux_save.c @@ -686,6 +686,12 @@ int xc_linux_save(int xc_handle, int io_fd, u32 dom, u32 max_iters, goto out; } + /* Canonicalize console mfn. */ + if ( !translate_mfn_to_pfn(&p_srec->resume_info.console_mfn) ) { + ERR("Console frame is not in range of pseudophys map"); + goto out; + } + print_stats( xc_handle, dom, 0, &stats, 0 ); /* Now write out each data page, canonicalising page tables as we go... */ diff --git a/tools/libxc/xenguest.h b/tools/libxc/xenguest.h index 10467e8476..b5797357b3 100644 --- a/tools/libxc/xenguest.h +++ b/tools/libxc/xenguest.h @@ -37,7 +37,8 @@ int xc_linux_save(int xc_handle, int fd, uint32_t dom, uint32_t max_iters, */ int xc_linux_restore(int xc_handle, int io_fd, uint32_t dom, unsigned long nr_pfns, unsigned int store_evtchn, - unsigned long *store_mfn); + unsigned long *store_mfn, unsigned int console_evtchn, + unsigned long *console_mfn); int xc_linux_build(int xc_handle, uint32_t domid, diff --git a/tools/python/xen/xend/XendCheckpoint.py b/tools/python/xen/xend/XendCheckpoint.py index 0157c25cd5..81d34b8f45 100644 --- a/tools/python/xen/xend/XendCheckpoint.py +++ b/tools/python/xen/xend/XendCheckpoint.py @@ -127,12 +127,18 @@ def restore(xd, fd): "not a valid guest state file: pfn count out of range") if dominfo.store_channel: - evtchn = dominfo.store_channel.port2 + store_evtchn = dominfo.store_channel.port2 else: - evtchn = 0 + store_evtchn = 0 + + if dominfo.console_channel: + console_evtchn = dominfo.console_channel.port2 + else: + console_evtchn = 0 cmd = [PATH_XC_RESTORE, str(xc.handle()), str(fd), - str(dominfo.id), str(nr_pfns), str(evtchn)] + str(dominfo.id), str(nr_pfns), + str(store_evtchn), str(console_evtchn)] log.info("[xc_restore] " + join(cmd)) child = xPopen3(cmd, True, -1, [fd, xc.handle()]) child.tochild.close() @@ -153,6 +159,7 @@ def restore(xd, fd): if fd == child.fromchild.fileno(): l = child.fromchild.readline() while l: + log.info(l.rstrip()) m = re.match(r"^(store-mfn) (\d+)\n$", l) if m: if dominfo.store_channel: @@ -162,7 +169,11 @@ def restore(xd, fd): dominfo.store_mfn, dominfo.store_channel) dominfo.exportToDB(save=True, sync=True) - log.info(l.rstrip()) + m = re.match(r"^(console-mfn) (\d+)\n$", l) + if m: + dominfo.console_mfn = int(m.group(2)) + dominfo.exportToDB(save=True, sync=True) + dominfo.publish_console() try: l = child.fromchild.readline() except: diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index cd7801a5b4..cd73b07a97 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -661,6 +661,7 @@ class XendDomainInfo: self.configure_restart() self.construct_image() self.configure() + self.publish_console() self.exportToDB(save=True) except Exception, ex: # Catch errors, cleanup and re-raise. @@ -1084,7 +1085,6 @@ class XendDomainInfo: self.configure_fields() self.create_devices() self.create_blkif() - self.publish_console() def create_blkif(self): """Create the block device interface (blkif) for the vm. diff --git a/tools/xcutils/xc_restore.c b/tools/xcutils/xc_restore.c index c5d3c84c4c..c94dbd3bbe 100644 --- a/tools/xcutils/xc_restore.c +++ b/tools/xcutils/xc_restore.c @@ -17,22 +17,27 @@ int main(int argc, char **argv) { - unsigned int xc_fd, io_fd, domid, nr_pfns, evtchn; + unsigned int xc_fd, io_fd, domid, nr_pfns, store_evtchn, console_evtchn; int ret; - unsigned long mfn; + unsigned long store_mfn, console_mfn; - if (argc != 6) - errx(1, "usage: %s xcfd iofd domid nr_pfns evtchn", argv[0]); + if (argc != 7) + errx(1, + "usage: %s xcfd iofd domid nr_pfns store_evtchn console_evtchn", + argv[0]); xc_fd = atoi(argv[1]); io_fd = atoi(argv[2]); domid = atoi(argv[3]); nr_pfns = atoi(argv[4]); - evtchn = atoi(argv[5]); + store_evtchn = atoi(argv[5]); + console_evtchn = atoi(argv[6]); - ret = xc_linux_restore(xc_fd, io_fd, domid, nr_pfns, evtchn, &mfn); + ret = xc_linux_restore(xc_fd, io_fd, domid, nr_pfns, store_evtchn, + &store_mfn, console_evtchn, &console_mfn); if (ret == 0) { - printf("store-mfn %li\n", mfn); + printf("store-mfn %li\n", store_mfn); + printf("console-mfn %li\n", console_mfn); fflush(stdout); } return ret; -- 2.30.2